package co.yixiang.controller.common;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import co.yixiang.common.enums.ResultCode;
import co.yixiang.common.utils.ResultUtil;
import co.yixiang.common.vo.ResultMessage;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/common")
public class RandomUserController {


    @RequestMapping("/randomUserInfo")
    public ResultMessage<Object> randomUser(String url){
        try {
            final String s = HttpUtil.get(url);
            JSONObject jsonObject = JSONUtil.parseObj(s);
            return ResultUtil.data(jsonObject);
        } catch (Exception e) {
            return ResultUtil.error(500,"第三方接口访问出错!");
        }
    }
}
